#include "ShotCutElement.h"
#include "../Clip/ShotCutClip.h"
#include "ShotCutTimeLine.h"
#include "../ShotCutReaderWriter/ShotCutWriter.h"
#include "../Effect/ShotCutEffect.h"
#include "../Caption/ShotCutCaption.h"
#include "CalcTemplateTimeline.h"

VideoElement::VideoElement(const JsonSetting& JsonData)
{
    JsonVideoData = JsonVideoClip(JsonData.VideosJsonData);
    TemplateTimeLine::ResetTemplateVideoClip(&JsonVideoData);
    Videos = VideoClip(JsonVideoData);
}

void VideoElement::AttachToTimeLine(ShotCutTimeLine TimeLine)
{
    TimeLine.AttachVideoClips(Videos);
}

AudioElement::AudioElement(const JsonSetting& JsonData, const JsonVideoClip& JsonVideoData)
{
    JsonAudioData = JsonAudioClip(JsonData.AudiosJsonData);
    TemplateTimeLine::ResetTemplateAudioClip(JsonVideoData, &JsonAudioData);
    Audios = AudioClip(JsonAudioData);
}

void AudioElement::AttachToTimeLine(ShotCutTimeLine TimeLine)
{
    TimeLine.AttachAudioClips(Audios);
}

VideoEffectElement::VideoEffectElement(const JsonSetting& JsonData, const JsonVideoClip& JsonVideoData)
{
    JsonVideoEffectData = JsonVideoEffectClip(JsonData.VideoEffectJsonData);
    TemplateTimeLine::ResetTemplateVideoEffectClip(JsonVideoData, &JsonVideoEffectData);
    VideoEffects = VideoEffectClip(JsonVideoEffectData);
}

void VideoEffectElement::AttachToTimeLine(ShotCutTimeLine TimeLine)
{
    TimeLine.AttachVideoEffectClips(VideoEffects);
}

MaskEffectElement::MaskEffectElement(const JsonSetting& JsonData, const JsonVideoClip& JsonVideoData)
{
    JsonMaskEffectData = JsonMaskEffect(JsonData.EffectJsonData);
    TemplateTimeLine::ResetTemplateMaskEffectClip(JsonVideoData, &JsonMaskEffectData);
    MaskEffects = MaskEffect(JsonMaskEffectData);
}

void MaskEffectElement::AttachToTimeLine(ShotCutTimeLine TimeLine)
{
    TimeLine.AttachMaskEffects(MaskEffects);
}

ImageEffectElement::ImageEffectElement(const JsonSetting& JsonData, const JsonVideoClip& JsonVideoData)
{
    JsonImageEffectData = JsonImageEffect(JsonData.EffectJsonData);
    TemplateTimeLine::ResetTemplateImageEffectClip(JsonVideoData, &JsonImageEffectData);
    ImageEffects = ImageEffect(JsonImageEffectData);
}

void ImageEffectElement::AttachToTimeLine(ShotCutTimeLine TimeLine)
{
    TimeLine.AttachImageEffects(ImageEffects);
}

FontEffectElement::FontEffectElement(const JsonSetting& JsonData, const JsonVideoClip& JsonVideoData)
{
    JsonFontEffectData = JsonFontEffect(JsonData.EffectJsonData);
    TemplateTimeLine::ResetTemplateFontEffectClip(JsonVideoData, &JsonFontEffectData);
    FontEffects = FontEffect(JsonFontEffectData);
}

void FontEffectElement::AttachToTimeLine(ShotCutTimeLine TimeLine)
{
    TimeLine.AttachFontEffects(FontEffects);
}

CaptionElement::CaptionElement(const JsonSetting& JsonData, const JsonVideoClip& JsonVideoData)
{
    JsonCaptionData = JsonShotCutCaption(JsonData.CaptionJsonData);
    TemplateTimeLine::ResetTemplateCaptionClip(JsonVideoData, &JsonCaptionData);
    Captions = ShotCutCaption(JsonCaptionData);
}

void CaptionElement::AttachToTimeLine(ShotCutTimeLine TimeLine)
{
    TimeLine.AttachCaption(Captions);
}
